package com.call.project.frame;

import org.springframework.core.io.ClassPathResource;

import javax.swing.*;
import java.awt.*;
import java.io.IOException;

/**
 Created by IntelliJ IDEA.
 User: wk
 Date: 2017-03-29 上午11:44
 */
public class WelcomeWindow extends JWindow {
    private int duration;
    Image       ii;
    int         iconWidth  = 650;
    int         iconHeight = 487;
    int         liveTime, currTime;

    public WelcomeWindow() {
        try {
            ii = this.getToolkit().getImage(new ClassPathResource("images/background_font.jpg").getURL());
        } catch (IOException e) {
            e.printStackTrace();
        }
        Dimension welcomeScreen = Toolkit.getDefaultToolkit().getScreenSize();
        int x = (welcomeScreen.width - iconWidth) / 2;
        int y = (welcomeScreen.height - iconHeight) / 2;
        currTime = liveTime;
        this.setBounds(x, y, iconWidth, iconHeight);
        this.setVisible(true);
        this.toFront();

    }

    public void showWelcomeWindow() {
        repaint();
        //            Thread.sleep(1000 * liveTime);

    }

    //    public void showWeclomeWindow() {
    //        this.showWelcomeWindow();
    //        this.dispose();
    //    }

    public void exit() {
        this.dispose();
    }

    @Override
    public void update(Graphics g) {
        paint(g);
    }

    @Override
    public void paint(Graphics g) {
        g.drawImage(ii, 0, 0, this);
    }
}
